package top.tangyh.lamp.care.mapper;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Param;
import top.tangyh.basic.base.mapper.SuperMapper;
import top.tangyh.lamp.care.entity.BWorkPlan;
import org.springframework.stereotype.Repository;
import top.tangyh.lamp.care.vo.result.WorkPlanOutVO;

import java.util.List;
import java.util.Set;

import static top.tangyh.lamp.common.constant.CommonConstant.NO_NUMBER;
import static top.tangyh.lamp.common.constant.CommonConstant.YES_NUMBER;

/**
 * <p>
 * Mapper 接口
 * 全局的排班表
 * </p>
 *
 * @author zqb
 * @date 2024-07-18 15:42:26
 * @create [2024-07-18 15:42:26] [zqb] [代码生成器生成]
 */
@Repository
public interface BWorkPlanMapper extends SuperMapper<BWorkPlan> {

    List<WorkPlanOutVO> selectListWorkPlanByQuery(@Param("workName") String workName, @Param("moduleId") String moduleId, @Param("roleId") Long roleId, @Param("workId") Long workId, @Param("enabled") Integer enabled);

    List<WorkPlanOutVO> selectPageListByQuery(@Param("workName") String workName, @Param("moduleId") String moduleId, @Param("roleId") Long roleId, @Param("workId") Long workId, @Param("enabled") Integer enabled,@Param("limitStart") Integer limitStart,@Param("limitEnd") Integer limitEnd);

    Long selectTotalCount(@Param("workName") String workName, @Param("moduleId") String moduleId, @Param("roleId") Long roleId, @Param("workId") Long workId, @Param("enabled") Integer enabled);


    default BWorkPlan selectOneByName(String workName) {
        LambdaQueryWrapper<BWorkPlan> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BWorkPlan::getWorkName, workName)
                .eq(BWorkPlan::getIsDeleted, NO_NUMBER);
        return this.selectOne(queryWrapper);
    }

    default List<BWorkPlan> selectListByIds(Set<Long> ids) {
        LambdaQueryWrapper<BWorkPlan> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(CollectionUtil.isNotEmpty(ids), BWorkPlan::getId, ids)
                .eq(BWorkPlan::getIsDeleted, NO_NUMBER)
                .eq(BWorkPlan::getEnabled, YES_NUMBER);
        return this.selectList(queryWrapper);
    }
}


